package com.kedi.healthcenter.controller;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kedi.healthcenter.service.PcOldLifeService;

/**
 * 
 *
 * @ClassName PcOldLifeController
 * @author: 陈辽逊
 * @date: 2019/7/13 12:07
 */
@Controller
public class PcOldLifeController {

	@Autowired
	public PcOldLifeService service;

	final static Logger logger = LoggerFactory.getLogger(PcOldLifeController.class);

	/**
	 * @Description: 获取前台提交的参数，指定映射方法名为/selectoldpart,床位预约列表
	 * @return 返回一个数据对象
	 */
	@RequestMapping("/selectoldlifepart")
	@ResponseBody
	public List<Map<String, Object>> selectoldlifepart() {
		return service.oldlifepart();
	}

	/**
	 * @Description: 获取前台提交的参数，指定映射方法名为/selectvolunteerall
	 * @return 返回一个数据对象
	 */
	@RequestMapping("/selectoldlifeall")
	@ResponseBody
	public Map<String, Object> selectoldlifeall(int oldlifeid) {
		return service.oldlifeall(oldlifeid);
	}

	@RequestMapping(value = "/insertibedoldlife", method = RequestMethod.POST)
	@ResponseBody
	public boolean insertibedoldlife(@RequestParam Map map) {
		try {
			boolean a = service.ibedoldlife(map);
			return a;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("插入失败");
			return false;
		}
	}

	@RequestMapping(value = "/updatebedoldlife", method = RequestMethod.POST)
	@ResponseBody
	public boolean updatebedoldlife(@RequestParam Map map) {
		try {
			boolean a = service.bedoldlife(map);
			return a;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("修改失败");
			return false;
		}
	}
}
